<?php

namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 *  礼记录物
 */
class GiftLog extends Model
{
    protected $table = 'gift_log';

    const TYPE = [
        1 => '普通礼物',
        2 => '系统礼物'
    ];

    //待领取
    const STATUS_WAIT = 0;
    //已领取
    const STATUS_OK = 1;
    //过期
    const STATUS_EXP = 2;
    const STATUS = [
        self::STATUS_WAIT => '待领取',
        self::STATUS_OK => '已领取',
        self::STATUS_EXP => '已失效',
    ];

    //普通赠送
    const FROM_SEND = 0;
    //注册-以系统名义赠送
    const FROM_SYS_REG = 1;
    //上线-以系统名义赠送
    const FROM_SYS_ONLINE = 2;
    //视频通话中赠送
    const FROM_VIDEO_CALL = 3;
    //语音通话中赠送
    const FROM_VOICE_CALL = 4;
    //主页搭讪
    const FROM_SUPER_CHAT = 5;
    //女用户给男用户的名义礼物
    const FROM_HOST_TO_USER = 6;
    //视频通话-男方回赠
    const FROM_VIDEO_CALL_BACK = 7;
    //视频通话-女用户免费赠送
    const FROM_VIDEO_CALL_FREE = 8;
    const FROM = [
        self::FROM_SEND => '普通礼物',
        self::FROM_SYS_ONLINE => '上线推送名义礼物',
        self::FROM_VIDEO_CALL => '视频通话中赠送',
        self::FROM_VOICE_CALL => '语音通话中赠送',
        self::FROM_SUPER_CHAT => '首页搭讪',
        self::FROM_HOST_TO_USER => '女用户给男用户的名义礼物',
        self::FROM_VIDEO_CALL_BACK => '视频通话-男方回赠',
        self::FROM_VIDEO_CALL_FREE => '视频通话-女用户免费赠送'
    ];

    public function userItem()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    public function userProfile()
    {
        return $this->belongsTo(UserProfile::class, 'user_id', 'user_id');
    }

    public function receiverProfile()
    {
        return $this->belongsTo(UserProfile::class, 'receive_user_id', 'user_id');
    }

    public function giftInfo()
    {
        return $this->belongsTo(Gift::class, 'gift_id', 'id');
    }
}
